package com.xinqing.test.Interview.algorithm;

import java.util.*;

/**
 * @Author:CHQ
 * @Date:2021/6/28 16:17
 * @Description
 */
public class InsertSort {
    public static void main(String args[]) {

        int[] nums = {1, 2, 3, 4};

        int[] nums_clone = nums.clone();
        Arrays.sort(nums_clone);
        int start = Integer.MAX_VALUE;
        int end = Integer.MIN_VALUE;

        System.out.println(end - start);


        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != nums_clone[i]) {
                start = Math.min(i, start);
                end = Math.max(i, end);
            }
        }

        int res = (end - start) > 0 ? (end - start + 1) : 0;
        System.out.println(res);




    }
}
